MBMixer software configuration:

This is my first MIDIBox project. I'll admit that it takes a bit of experience
to figure out where to make changes. Here's a description of my current system,
and then a list of modifications you might want to make, and where you can go
to make them.

The "reference system" that I have built includes a MIOS core, a 2X20 Display,
and a DINX1 input chip, connected to an encoder with pushbutton. I have 4
PGA4311 chips connected, so I can mix eight audio pairs.
Basic configuration:

Figure out how many audio pairs your board will support. Add one for every
PGA2311, and two for every PGA4311 used in your board. Find and open file 
"pga.inc". Near line 26, find \\
#define pairs 8 \\
and change it to your number.

Now find and open file "user_lcd.inc" and look near lines 101-116 for
TEXT_CHAN_0 STRING 9,0x04,"CD Player"
These are where you may name your input sources. The first part of the line,
"TEXT_CHAN_0", is the label for this location, and should not be changed. The
"STRING" word calls a macro to store this information. The "9" is the length of
the name you give this channel, and the "0x04" described where to write this on
the display (four spaces into the first line). Finally you get to name the
input channel. Don't forget to count how long it is and write it back to the
length number. Once this is done your audio sources will be identified by name
on the display.

Now build this project in MPLab, then load the result into MIOS studio and send
it to your core. After reset, it should be mixing away.
On reset, all channels will be set to Volume 37, Balance 64. This should give
a near 0dB balanced mix of all channels. You can change the start volume level in file "pga.inc" near lines 28, 29 \\
#define start_volume d'37' \\
#define start_balance d'64' \\

If you don't want the start settings sent to MIDI_OUT, near line 92, remove the semicolon before the return. Now the starting MIDI settings won't be sent.

Even if you have NO PGA chips connected, this application can be used by a simple
CORE + Display to show you the incoming Volume and Balance settings, along with
names for each audio channel.

If you want to have one encoder for each channel, you'll need to make a few
adjustments. First, instead of a DINX1, you'll probably need the bigger DINX4,
which will support up to 16 encoders per DINX4 board. You'll need to edit file
"mios_tables.inc" starting down around line 390 to describe each encoder.
ENC_ENTRY 1,0,MIOS_ENC_MODE_NON_DETENTED
After "ENC_ENTRY" on each line is the shift register number. There is one shift register on a DINX1 and four on a DINX4. Each shift register has eight input pins,
numbered 0 to 7. You are describing which shift register, and to which pins each encoder is connected. Since each encoder uses two pins, the pin number here should always be even. 0, 2, 4, or 6.

So each line starts "ENC_ENTRY, then the Shift register number, pin number, and
the mode that works best for your encoder. Now MIOS can see your encoders, We need 
to describe what to do with them all. In file main.asm, near line 283 is some code labeled USER_ENC_NotifyChange. 

Near the beginning of this code, add \\
movff MIOS_PARAMETER1, MIDI_DISP_CHAN \\
Now each encoder will go to it's own channel, instead of the pushbutton cycling between the choices.

Most of the code is heavily commented, read it for more details.
I mean it's REALLY got a lot of comments. Too Many. But that gives a
lot of clues to people learning to read PIC ASM.

If you want to try the stereo level meter display instead of the dB display,
go to user_lcd.inc near lines 39 and 40, comment out the "call DBMeter" and
remove the comment marker from "call StereoMeter". I expect the StereoMeter
will only look right with a small number of displays.

pga.inc is the code for talking to the PGA chips.
setlevels.inc converts the MIDI Volume and Balance settings into individual gain settings for each left and right channel.

logbyte.inc can convert from linear to log and back again.
user_lcd.inc handles most of the display stuff, including channel names and the stereo meter displays.
main.asm pulls it all together, and includes most of the MIOS connections.


Current Firmware: Source and .syx \\
{{pga:mbmixerv1.zip}}